package com.yb.web.global.servlet;

import java.util.Timer;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.Logger;

public class CacheInMemoryServlet extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5842016980685305102L;
	private static boolean debug = true;// 是否debug模式
	public static Logger log = Logger.getLogger(CacheInMemoryServlet.class);

	@SuppressWarnings("unchecked")
	public void init() throws ServletException {
		// 从web.xml中读取debug模式
		debug = (new Boolean(getInitParameter("debug"))).booleanValue();
		if (debug)
			System.out.println("\r\n---- Debug model on ----");
		if (debug)
			System.out
					.println("\r\n---- CacheInMemoryServlet initialization started ----");
		if (debug)
			System.out
					.println("---- CacheInMemoryServlet initialization completed ----\r\n");
		if (debug)
			System.out.println("---- Task on ----\r\n");
		Timer timer = new Timer();
		timer.schedule(new TaskUtil(), 1000, 60000 * 5 );// * 60在系统启动后1S开始执行任务调度，每隔1个小时执行一次
		if (debug)
			log.info("---- Task on success ----\r\n");
	}
}
